﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MvcApplication.Common
{
    public class MySqlADO : ADO
    {
        public static DataSet GetDataSet(string connStr, string commandText, params MySqlParameter[] parameters)
        {
            using (var connection = new MySqlConnection(connStr))
            {
                var mysqlCommand = new MySqlCommand();
                var adapter = new MySqlDataAdapter(mysqlCommand);

                return ExecuteDataSet(connection, mysqlCommand, adapter, null, commandText, CommandType.Text, parameters);
            }
        }

        public static DbDataReader GetDataReader(string connStr, string commandText, params MySqlParameter[] parameters)
        {
            var connection = new MySqlConnection(connStr);
            var mysqlCommand = new MySqlCommand();
            return ExecuteDataReader(connection, mysqlCommand, null, CommandType.Text, commandText, parameters);
        }
    }
}
